package com.central.product.controller

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import com.central.common.entity.DrawCategory
import com.central.common.model.CommonResult
import com.central.common.model.PageVo
import com.central.product.service.DrawCategoryService
import io.swagger.annotations.Api
import io.swagger.annotations.ApiOperation
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

/**
 * @author  fly
 * @date  2021/5/28 15:17
 * @version 1.0
 */
@Api(tags = ["(管理系统) 盒蛋分类api"])
@RestController
@RequestMapping("/back/drawCategory")
open class BackDrawCategoryController {

    @Autowired
    private lateinit var drawCategoryService: DrawCategoryService


    @ApiOperation("通过id获取")
    @GetMapping("/get/{id}")
    fun get(@PathVariable id: Long): CommonResult<DrawCategory> = drawCategoryService.get(id)

    @ApiOperation(value = "获取全部数据")
    @GetMapping("/getAll")
    fun getAll(): CommonResult<List<DrawCategory>> = drawCategoryService.getAll()


    @ApiOperation("分页获取")
    @GetMapping("/getByPage")
    fun getByPage(pageVo: PageVo): CommonResult<Page<DrawCategory>> = drawCategoryService.getByPage(pageVo)


    @ApiOperation("编辑或更新数据")
    @PostMapping("/saveOrUpdateDrawCategory")
    fun saveOrUpdateDrawCategory(drawCategory: DrawCategory): CommonResult<DrawCategory> = drawCategoryService.saveOrUpdateDrawCategory(drawCategory)


    @ApiOperation("批量通过id删除")
    @PostMapping("/delAllByIds")
    fun delAllByIds(ids: Array<String>): CommonResult<Any> = drawCategoryService.delAllByIds(ids)
}
